package demo

import (
	"encoding/json"
	"fmt"
)

func Pagination() {
	Init()

	var Advanceds []*Advanced
	limit := 2
	page := 3
	offset := (page - 1) * limit
	var total int64
	DB.Debug().Model(&Advanced{}).Count(&total)
	DB.Limit(limit).Offset(offset).Find(&Advanceds)

	json, _ := json.Marshal(Advanceds)
	fmt.Println(string(json))
	fmt.Println(total)
}
